package com.yc.demo.d0729;

import com.yc.demo.util.Utils;
import com.yc.demo.vo.Result;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "MyNameServlet", value = "/myName.s")
public class MyNameServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        final HttpSession session = request.getSession();
        final Object loginedUser = session.getAttribute("loginedUser");
        Result result;
        if(loginedUser==null){
            result = new Result(0, "未登录", null);
        } else {
            result = new Result(1, "已登录", loginedUser);
        }
        Utils.result(response, result);
    }

    // http://localhost/web_demo_war_exploded/login.do?username=yc&password=123
    // http://localhost/web_demo_war_exploded/myName.s
}
